package com.cmes.core;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

/**
 * 分页辅助类
 *
 * @author Bruce.Gong
 * @since 1.0.0-SNAPSHOT
 */
@EqualsAndHashCode
@Getter
@Setter
@NoArgsConstructor
public class Page<T> implements Serializable {

    /**
     * 当前页
     */
    protected int pageNum = 1;

    /**
     * 每页的数量
     */
    protected int pageSize = 20;

    /**
     * 总记录数
     */
    protected long totalRow;

    /**
     * 数据
     */
    protected List<T> rows;

    /**
     * 是否查询总条数
     */
    @JsonIgnore
    protected boolean searchCount = true;

    public Page(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public Page(int pageNum, int pageSize, boolean searchCount) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.searchCount = searchCount;
    }

}
